package com.edu.filter;

import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.edu.entity.Prom;
import com.edu.service.impl.indexServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

@WebFilter("/index.jsp")
public class indexFilter implements Filter {
	indexServiceImpl isi = new indexServiceImpl();
	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		// TODO Auto-generated method stub
		HttpServletRequest httpRequest = (HttpServletRequest) request;
		HttpSession session = httpRequest.getSession();
		    session.setAttribute("PromList", isi.serviceFIndProm()); // 作为JSON字符串存储
		    chain.doFilter(request, response);
	}
    // 这个Filter只会对/specificPage.jsp请求生效
}
